package com.voole.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.mapping.StatementType;
import org.springframework.stereotype.Repository;

import com.voole.entity.SysAuthority;
import com.voole.entity.SysUser;

@Repository
public interface SysUserDao {

	@Select(value="SELECT * FROM sys_user ORDER BY account ASC")
	List<SysUser> getList();
	
	@Select(value="SELECT * FROM sys_user WHERE id = ${param}")
	SysUser getSysUser(@Param(value="param")Integer userId);
	
	@Select(value="SELECT * FROM sys_user WHERE account = #{param}")
	SysUser getSysUserByAccount(@Param(value="param")String account);
	
	@Select(value="SELECT * FROM sys_user ORDER BY account ASC LIMIT #{start}, #{end}")
	List<SysUser> findByPage(@Param(value="start")Integer start, @Param(value="end")Integer end);

	@Select(value="SELECT count(1) FROM sys_user")
	Integer getCount();
	
	@Insert("INSERT INTO sys_user (`account`, `name`, `password`, `createtime`, `updatetime`, `status`) VALUES (#{account}, #{name}, #{password}, #{createtime}, #{updatetime}, #{status})")  
	@Options(useGeneratedKeys = true, keyProperty = "id")
	Integer addSysUser(SysUser sysUser);
	
}